package com.entrogy.dao;

import com.alibaba.fastjson.JSONObject;
import com.entrogy.bean.MeetingApplyRecordEntity;
import com.entrogy.bean.MeetingRoomEntity;
import com.entrogy.bean.PersonMeetingAttendanceEntity;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @ClassName MeetingRoomMapper
 * @Description
 * @Author luoxingjiang
 * @Date 2019/8/6 0006 下午 3:45
 * @Version 1.0
 **/
@Repository
public interface MeetingRoomMapper {

    /**
     * 查询会议室列表
     * @param meetingRoomName
     * @param schoolCode
     * @param meetingRoomId
     * @return
     */
    List<MeetingRoomEntity> listMeetingRoom(@Param(value = "meetingRoomName") String meetingRoomName, @Param(value = "schoolCode") Integer schoolCode, @Param("meetingRoomId") Integer meetingRoomId);

    /**
     * 查询会议室的禁用时间段，即在审核中的会议以及审核通过的会议锁定的会议室时间段
     * @param meetingRoomId
     * @param selectDate
     * @return
     */
    List<JSONObject> listMeetingRoomDisableTime(@Param(value = "meetingRoomId") Integer meetingRoomId, @Param(value = "selectDate") String selectDate);

    /**
     * 插入会议室申请记录
     * @param meetingApplyRecordEntity
     * @return
     */
    Integer insertMeetingApplyRecord(MeetingApplyRecordEntity meetingApplyRecordEntity);

    /**
     * 插入参会人员记录
     * @param meetingId
     * @param meetingPersonIdList
     * @return
     */
    Integer insertMeetingPersonRecord(@Param(value = "meetingId") Integer meetingId, @Param(value = "meetingPersonIdList") List<String> meetingPersonIdList);

    /**
     * 查询会议室管理员的信息
     * @param meetingRoomId
     * @return
     */
    String getMeetingRoomAdminPhone(Integer meetingRoomId);

    /**
     * 会议室管理员查看申请记录
     * @param userId
     * @return
     */
    List<MeetingApplyRecordEntity> listMeetingApplyRecord(String userId);

    /**
     * 会议室管理员查看申请记录详情
     * @param meetingRoomApplyId
     * @return
     */
    MeetingApplyRecordEntity getApplyDetail(Integer meetingRoomApplyId);

    /**
     * 更新某条申请的状态
     * @param meetingRoomApplyId
     * @param audited
     * @param opinion
     * @return
     */
    boolean updateMeetingRoomApplyRecord(@Param(value = "meetingRoomApplyId") Integer meetingRoomApplyId, @Param(value = "audited") Integer audited, @Param(value = "opinion")String opinion);

    /**
     * 查询申请人电话号码
     * @param meetingRoomApplyId
     * @return
     */
    String getApplyUserPhone(Integer meetingRoomApplyId);

    /**
     * 查询所有参会人员的电话号码
     * @param meetingRoomApplyId
     * @return
     */
    List<String> listMeetingPersonPhone(Integer meetingRoomApplyId);

    /**
     * 查询会议室列表作为下拉框选择
     * @return
     */
    List<JSONObject> getMeetingRoomListSimple(Integer schoolCode);

    /**
     * 教职员工查看参与的会议
     * @param userId
     * @return
     */
    List<MeetingApplyRecordEntity> listAttendanceMeeting(String userId);

    /**
     * 教职员工查看申请的会议
     * @param userId
     * @return
     */
    List<MeetingApplyRecordEntity> listMyApply(String userId);

    /**
     * 查询管理该会议室的管理员的基本信息
     * @param meetingRoomId
     * @return
     */
    String getManagerInfo(Integer meetingRoomId);

    /**
     * 新增会议室
     * @param meetingRoom
     * @return
     */
    Integer insertMeetingRoom(MeetingRoomEntity meetingRoom);

    /**
     * 查询该会议室是否需要审核
     * @param meetingRoomId
     * @return
     */
    Integer getRequireAuditCode(Integer meetingRoomId);

    /**
     * 查询需要申请记录总数
     * @param userId
     * @return
     */
    Integer countMeetingApplyRecord(String userId);

    /**
     * 查询自己申请记录总数
     * @param userId
     * @return
     */
    Integer countMyApply(String userId);

    /**
     * 查询自己的参会记录总数
     * @param userId
     * @return
     */
    Integer countAttendanceMeeting(String userId);

    /**
     * 查询出该会议的开始日期以及开始时间和结束时间
     * @param meetingRoomApplyId
     * @return
     */
    JSONObject getMeetingDate(Integer meetingRoomApplyId);

    /**
     * 根据会议查询会议室id
     * @param meetingRoomApplyId
     * @return
     */
    Integer getMeetingRoomId(Integer meetingRoomApplyId);

    /**
     * 查询会议室的设备
     * @param meetingRoomId
     * @return
     */
    List<String> getMeetingRoomDevice(Integer meetingRoomId);

    /**
     * 查询在该会议室的设备上，在开会截止时间的当天有打卡记录的人员记录
     * @param meetingRoomApplyId
     * @param tableName
     * @param meetingEndTime
     * @param deviceIds
     * @return
     */
    List<PersonMeetingAttendanceEntity> listAttendancePerson(@Param(value = "meetingRoomApplyId") Integer meetingRoomApplyId, @Param(value = "tableName") String tableName, @Param(value = "meetingEndTime") String meetingEndTime, @Param(value = "deviceIds") List<String> deviceIds);

    /**
     * 查询所有会议人员名单
     * @param meetingRoomApplyId
     * @return
     */
    List<PersonMeetingAttendanceEntity> listAllMeetingPerson(Integer meetingRoomApplyId);

    /**
     * 更新会议室信息
     * @param meetingRoom
     * @return
     */
    Integer updateMeetingRoom(MeetingRoomEntity meetingRoom);

    /**
     * 查询出该次会议要推送的设备（即所在会议室的设备）
     * @param meetingApplyRecord
     * @return
     */
    List<String> listMeetingRoomDevice(MeetingApplyRecordEntity meetingApplyRecord);

    /**
     * 查询参加这次会议的人员的实义德id用于推送通行权限
     * @param meetingId
     * @return
     */
    List<String> listMeetingPersonThdid(Integer meetingId);

    /**
     * 查询管理人员管理那个会议室
     * @param uid
     * @return
     */
    List<Integer> listMeetingRoomIdByManagerId(String uid);

    /**
     * 查询该校处于待审核的申请id
     * @param schoolCode
     * @param uid
     * @return
     */
    List<Integer> listApplyId(@Param("schoolCode") Integer schoolCode, @Param("uid") String uid);
}
